#include <stdio.h>
#include <assert.h>

int main(int argc, char* argv[]) {
	if (argc != 2) {
		printf("Useage: %s file", argv[0]);
		return 0;
	}

	{
		FILE* pf;
		unsigned lines = 0, filebytes = 0;

		pf = fopen(argv[1], "rb");
		assert(pf);

		while (1) {
			size_t rsize;
			static unsigned int rn;
			static unsigned char buf[32];
			rsize = fread(buf, 1, 32, pf);
			if (rsize == 0) {
				break;
			}
			filebytes += rsize;

			{
				size_t i;
				int mark = 1;

				for (i = 0; i < rsize; ++i) {
					if (mark) {
#ifdef W32
						printf("line 0x%08x - ", lines);
#elif define(W64)
						printf("line 0x%016x - ", lines);
#endif
						mark = 0;
					}
					printf("%02x ", buf[i]);
					++rn;

					if (rn % 16 == 0) {
						++lines;
						mark = 1;
						putchar('\n');
					}
				}
			}
		}
		fclose(pf);

		printf("\n%s %u bytes\n", argv[1], filebytes);
	}
	return 0;
}
